package hibernate.administratorAccount;

import java.util.*;
import java.lang.*;

public class AttendenceRecord implements Comparable,java.io.Serializable{
	
	public static class Type{
		private static Type late=new Type("LATE");
		private static Type absent=new Type("ABSENT");
		private static Type ontime=new Type("ONTIME");
		private static Type askingforleave=new Type("ASKINGFORLEAVE");
		private String name;
		
		private Type(String n){
			this.name=n;
		}
		
		public String toString(){
			return name;
		}
		
		public static Type getLate(){return late;}
		public static Type getAbsent(){return absent;}
		public static Type getOntime(){return ontime;}
		public static Type getAskingforleave(){return askingforleave;}
		
		public static Type parseType(String info){
			if(info.equals(late.toString()))
				return late;
			else if(info.equals(absent.toString()))
				return absent;
			else if(info.equals(ontime.toString()))
				return ontime;
			else return askingforleave;
		}
	}
	
	private Type type;
	private String note=null;
	private Date date=null;
	private Long id;
	private AttendenceInfo attendenceInfo;
	
	public void setAttendenceInfo(AttendenceInfo info){this.attendenceInfo=attendenceInfo;}
	
	public AttendenceInfo getAttendenceInfo(){return attendenceInfo;}
	
	public void setType(String name){
		if(name.equals("LATE"))
			type=Type.getLate();
		else if(name.equals("ABSENT"))
			type=Type.getAbsent();
		else if(name.equals("ONTIME"))
			type=Type.getOntime();
		else if(name.equals("ASKINGFORLEAVE"))
			type=Type.getAskingforleave();
		else throw new java.lang.IllegalArgumentException("no this type");
	}
	
	public String getType(){
		return type.toString();
	}
	
	public void setDate(Date time){
		date=time;
	}
	
	public Date getDate(){
		return date;
	}
	
	public void setNote(String note){
		this.note=note;
	}
	
	public String getNote(){
		return note;
	}
	
	public void setId(Long i){
		id=i;
	}
	
	public Long getId(){
		return id;
	}
	
	public int compareTo(Object other){
		return this.date.compareTo(((AttendenceRecord)other).date);
	}
	
	public Type getConcreteType(){return this.type;}
}
